﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using Facade.Manager.Abstract;

using DataAccess.Repositories;

using Domain.Model;

namespace Facade.Manager
{
    public class ProgramManager : AbstractManager
    {
        #region Members

        private static readonly ProgramManager instance = new ProgramManager();

        // ProgramRepository
        private ProgramRepository programRepository;

        // ProjectRepository
        private ProjectRepository projectRepository;

        #endregion

        #region Properties

        public List<Project> Projects { get; private set; }

        public Project CurrentProject { get; private set; }

        #endregion

        #region ProgramManager

        private ProgramManager()
        {
            // instantiate ProgramRepository
            programRepository = new ProgramRepository();

            // instantiate ProjectRepository
            projectRepository = new ProjectRepository();
        }

        public static ProgramManager Instance
        {
            get 
            {
                return instance;
            }
        }

        #endregion

        #region public methods

        public List<Program> GetAllPrograms()
        {
            return programRepository.GetAll() as List<Program>;
        }

        public Project GetProjectById(int id)
        {
            return projectRepository.GetById(id);
        }

        public void AddProject(int programId, Project project)
        {
            Program program = PortfolioManager.Instance.GetProgramById(programId);
            program.AddProject(project);

            projectRepository.Add(project);
        }

        #endregion

        #region private methods

        #endregion
    }
}